<template>
  <div>
      <div class="scrollerWrap" >
    <scroller   :on-refresh = "refresh" :on-infinite="infinite" :noDataText="''"   ref="myscroller">
          <div>
            <div  v-for="(order,index) in dataList"
        :key="index"
        class="green-box kaidan_box vux-1px-t click_to_green kaidan_info_list_my"  @click="toCheckDetail(order.id,order.checkOrderId)">
          <div class="kaidan_box_top">
           <flexbox :gutter="0">
              <flexbox-item :span="5/10" class="user_group_div">
                <span class="span_status">{{ order.statusText }}</span>
                <span class="span_time">{{ order.showTimeStr}}</span>
              </flexbox-item>
              <flexbox-item :span="5/10" align="right">
                <span class="span_name">{{ order.no}}</span>
              </flexbox-item>
            </flexbox>
          </div>
           <ul class="kaidan_buttom click_to_green">
            <li class="right_li">
              <span class="border_radus" :class="order.borderClass">{{ order.orderPoints }}分</span>
              {{order.orderCheckBigCateName}}-{{order.orderCheckItemName}}
            </li>
          </ul>
        </div>
           <div class="list_no_data1" v-if="dataList.length==0&&!isLodding">没有发起过申诉!</div>
                <div class="list_no_data1" v-if="dataList.length==0&&isLodding">数据加载中</div>
        </div>
     </scroller>
</div>
  </div>
</template>

<script>
import appealApplyService from '../../shared/service/appealApplyService'

import {
  Swipeout,
  SwipeoutItem,
  SwipeoutButton,
  dateFormat,
} from "vux";

export default {
  components: {
     Swipeout,
    SwipeoutItem,
    SwipeoutButton,
    dateFormat,
  },
  name: "myAppealApply",
  props: ["okText","noText"], /* okEvent 文件上传完成事件 */
  data() {
    var data =  {
      dataNum: 0,
      loginUserId:this.$cookie.getUserId(),
      dataList:[],
      isLodding:true,
    };

    data.dataPage={
      pageNum:0,
      pages:0
    };

    return data;
  },
  created() {
      this.doSearchData(1);
  },
  methods: {
    //列表-编辑 , 开单按钮
    toCheckDetail(id,checkOrderId) {
      this.$router.push({ name: "appeal_apply_detail", query: { viewType: "student" ,appealApplyId: id ,checkOrderId: checkOrderId } });
    },
    doSearchData(page,fn){
       var param= {
         studentUserId:this.loginUserId,
       };
      this.isLodding=true;
      appealApplyService.getMyAppealOrderPage(page,param).then((res)=>{
         this.isLodding=false;
         var data = res.data;
         this.dataPage.pageNum=page;
         this.dataPage.pages=data.pages;
         this.dataNum=data.total;
         for (let i = 0; i < data.list.length; i++) {
           let po = data.list[i];
           po = this.dealData(po);
         }
         if(page==1){
           this.dataList = data.list;
         }else{
           this.dataList = this.dataList.concat(data.list);
         }
         if(fn)fn();
       });
       
    },
     dealData(po){
        po.borderClass = po.orderScoringType==1 ? 'color_green' : 'color_red';
        //审批状态，学生撤诉：0，待审批：1，审批通过：2，审批不通过：3
        switch(po.authState){
                case 0:
                    po.statusText= "撤诉";
                    break;
                case 1:
                    po.statusText= "待审核";
                    break;
                case 2:
                    po.statusText= "审核通过";
                    po.borderClass='color_grey_white'
                    break;
                case 3:
                    po.statusText= "驳回";
                    po.borderClass='color_grey_white'
                    break;
        }
        po.showTimeStr = dateFormat(this.$commonUtil.getDate(po.creTime), 'YY/MM/DD HH:mm');
         return po;
    },
     //下拉刷新
    refresh(done) {
      this.doSearchData(1,done);
    },
    //下拉刷新
    infinite(done) {
      console.log("触发下拉-=------------");
      if(this.dataPage.pages >0 && this.dataPage.pages<=this.dataPage.pageNum){
          this.$refs.myscroller.finishInfinite(true);
          return;
      }
        if(this.dataPage.pages == 0 ){
          this.$refs.myscroller.finishInfinite(true);
          return;
      }
      this.doSearchData(this.dataPage.pageNum+1,done);
    },
  }
};
</script>

<style scoped>

</style>